<script setup>
import {
  Edit,
  Delete
} from '@element-plus/icons-vue'

import { ref } from 'vue'




const queryTime = ref([])


const channels = ref([
  {
    "name": "小米",
    "value": "xm",
  },
  {
    "name": "360",
    "value": "360",
  },
  {
    "name": "掌育",
    "value": "zy",
  }
  ,
  {
    "name": "三基同创",
    "value": "sjtc",
  }
  ,
  {
    "name": "华为",
    "value": "hw",
  }
])





const channel = ref('')


//文章列表数据模型
const channelDatas = ref([

])


//分页条数据模型
const pageNum = ref(1)//当前页
const total = ref(20)//总条数
const pageSize = ref(15)//每页条数

//当每页条数发生了变化，调用此函数
const onSizeChange = (size) => {
  pageSize.value = size
  channelDataList()
}
//当前页码发生变化，调用此函数
const onCurrentChange = (num) => {
  pageNum.value = num
  channelDataList()
}



import { channelDataListService } from '@/api/channelData.js'



import { Plus } from '@element-plus/icons-vue'
import { QuillEditor } from '@vueup/vue-quill'
import '@vueup/vue-quill/dist/vue-quill.snow.css'







const channelDataList = async () => {

  let params = {
    pageNum: pageNum.value,
    pageSize: pageSize.value,
    channel:channel.value?channel.value:null ,
    timeFrom: queryTime.value ? queryTime.value[0] : null,
    timeEnd: queryTime.value ? queryTime.value[1] : null,
  }
  let result = await channelDataListService(params);
  //渲染视图
  total.value = result.data.total;
  channelDatas.value = result.data.records;


}


channelDataList();

</script>
<template>
  <el-card class="page-container">
    <template #header>
      <div class="header">
        <span>发布数据统计</span>
      </div>
    </template>
    <!-- 搜索表单 -->
    <el-form inline>
      <el-form-item label="时间：">
        <el-date-picker v-model="queryTime" type="daterange" align="right" unlink-panels range-separator="至"
          start-placeholder="开始日期" end-placeholder="结束日期" value-format="YYYY-MM-DD">
        </el-date-picker>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="articleList">搜索</el-button>
      </el-form-item>
    </el-form>
    <!-- 文章列表 -->
    <el-table :data="channelDatas" border style="width: 100%">
      <el-table-column label="渠道" width="200" prop="channelFullName"></el-table-column>
      <el-table-column label="日期" prop="dayTime"></el-table-column>
      <el-table-column label="新增用户" prop="addUserCount"> </el-table-column>
      <el-table-column label="付费用户" prop="payUserCount"></el-table-column>
      <el-table-column label="付费金额" prop="payAmount"></el-table-column>
      <el-table-column label="付费订单数" prop="payOrderCount"></el-table-column>
      <el-table-column label="活跃用户" prop="activeUserCount"></el-table-column>
      <el-table-column label="ARPPU" prop="arppu"></el-table-column>
      <el-table-column label="ARPU" prop="arpu"></el-table-column>
    
      <template #empty>
        <el-empty description="没有数据" />
      </template>
    </el-table>
    <!-- 分页条 -->
    <el-pagination v-model:current-page="pageNum" v-model:page-size="pageSize" :page-sizes="[3, 5, 10, 15]"
      layout="jumper, total, sizes, prev, pager, next" background :total="total" @size-change="onSizeChange"
      @current-change="onCurrentChange" style="margin-top: 20px; justify-content: flex-end" />




  </el-card>
</template>
<style lang="scss" scoped>
.page-container {
  min-height: 100%;
  box-sizing: border-box;

  .header {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
}


/* 抽屉样式 */
.avatar-uploader {
  :deep() {
    .avatar {
      width: 178px;
      height: 178px;
      display: block;
    }

    .el-upload {
      border: 1px dashed var(--el-border-color);
      border-radius: 6px;
      cursor: pointer;
      position: relative;
      overflow: hidden;
      transition: var(--el-transition-duration-fast);
    }

    .el-upload:hover {
      border-color: var(--el-color-primary);
    }

    .el-icon.avatar-uploader-icon {
      font-size: 28px;
      color: #8c939d;
      width: 178px;
      height: 178px;
      text-align: center;
    }
  }
}

.editor {
  width: 100%;

  :deep(.ql-editor) {
    min-height: 200px;
  }
}
</style>